home *** CD-ROM | disk | FTP | other *** search
Text File | 2004-12-07 | 36.7 KB | 1,178 lines |
- // GETINFO SCRIPTING
- // AllocinΘ (FR) - Recherche de films - by ScorEpioN
-
- (***************************************************
- * Movie importation script for: *
- * AllocinΘ France, http://www.allocine.fr *
- * *
- * Script AllocinΘ v20 du 06/12/2004 by ScorEpioN *
- * *
- * Ancienne version : *
- * faite par Antoine Potten *
- * amΘliorations par Soltan *
- * *
- * For use with Ant Movie Catalog 3.4.3 *
- * www.antp.be/software/moviecatalog *
- * *
- * This program is free software; you can *
- * redistribute it and/or modify it under the *
- * terms of the GNU General Public License as *
- * published by the Free Software Foundation; *
- * either version 2 of the License, or (at your *
- * option) any later version. *
- ***************************************************)
-
- program Allocine_FR;
- const
- GrandeImage = 1;
- { 2: Prend la grande image
- 1: Prend l'affiche 0: Pas d'image }
- PlusdActeurs = 1;
- { 2: Prend la liste complΦte des acteurs
- 1: Prend les noms des acteurs de la page principale, 0: Pas d'acteurs }
- PlusdeScene = 1;
- { 2 : Prend la liste complΦte des scenes de tournage
- 1 : Prend les scenes de tournage de la page principale
- 0 : Ne prend pas les secrets de tournage }
- Note = 2;
- { 2 : Prend les notes dans le champs rating et dans le champs commentaire
- 1 : Prend les notes dans le champs rating avec une preference pour la note des spectateurs
- 0 : Ne prend pas les notes ni dans le champs commentaire ni dans le champs rating }
- ConfirmTitre = 1;
- { 1: Demande le titre avant de lancer le script
- 2: Ne demande pas le titre avant de lancer le script, 0 : Ne demande aucune comfirmation, 3 : Aucune Confirmation Premier Film si multiples resultats}
- // Pour rΘcupΘrer ou non un champs
- TitreOrignalConst = True;
- TitreTraduitConst = True;
- RealisateurConst = True;
- PaysConst = True;
- CategorieConst = True;
- AnneeConst = True;
- DureeConst = True;
- AdresseWebConst = True;
- SynopsisConst = True;
- CommentWithSynopsis = False;
- ImageAmazonFR = False;
-
- var
- MovieName, Adresse, AdressePlus, La_liste, LaGrandeImage, LaPremiereGrandeImage, Reponse, AdresseSuivant, AdressePrecedent, LePremierFilmAdresse, strTemp, aucunAmazon : string;
- numPage, numPageG, numPageR, grandeTaille, premiereTaille, compteur, premiereExecution, numTemp : Integer;
-
- //------------------------------------------------------------------------------
- // TROUVE UNE SOUS-CHAINE DE CARACTERE DANS UNE CHAINE
- //------------------------------------------------------------------------------
-
- function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
- var
- i: Integer;
- begin
- result := -1;
- if StartAt < 0 then
- StartAt := 0;
- for i := StartAt to List.Count-1 do
- if Pos(Pattern, List.GetString(i)) <> 0 then
- begin
- result := i;
- Break;
- end;
- end;
-
- //------------------------------------------------------------------------------
- // ANALYSE DE LA PAGE DE RECHERCHES
- //------------------------------------------------------------------------------
-
- procedure AnalyzePage(Address: string);
- var
- Page: TStringList;
- LineNr: Integer;
- Line: string;
- BeginPos, EndPos : Integer;
- begin
- Page := TStringList.Create;
- Page.Text := GetPage(Address);
-
- if pos('Pas de rΘsultats',Page.Text) <> 0 then
- begin
- if (ConfirmTitre = 1) or (ConfirmTitre = 2) then
- begin
- showmessage('Aucun film trouvΘ pour : '+MovieName);
- exit;
- end else
- begin
- SetField(fieldURL, 'Allo-cinΘ : aucun rΘsultat');
- exit;
- end;
- end;
-
- if pos('Recherche :', Page.Text) = 0 then
- begin
- Adresse := Address;
- AnalyzeMoviePage();
- end else
- begin
- PickTreeClear;
- LineNr := FindLine('<h3><b>Films <h4>', Page, 0);
- if LineNr > -1 then
- begin
- EndPos := length(Page.Text);
- Line := copy(Page.Text,1,EndPos);
- BeginPos := Pos('<td colspan="2" valign="top">', Line);
- Delete(Line, 1, BeginPos);
- EndPos := length(Line);
- Line := copy(Line,1,EndPos);
- PickTreeAdd('Films trouvΘs pour ' + MovieName + ' :', '');
- AddMoviesTitles(Line);
- PickTreeAdd(' ', '');
- PickTreeAdd('Verifier si vous avez la derniΦre version', 'version');
- end;
- if compteur = 1 then
- begin
- compteur := 0;
- AnalyzeMoviePage();
- exit;
- end else if (ConfirmTitre = 1) or (ConfirmTitre = 2) then
- begin
- begin
- if PickTreeExec(Address) then
- begin
- Adresse := Address;
- if (Adresse = 'version') then
- begin
- verifVersion();
- end else
- if (Adresse = AdressePlus) then
- begin
- numPageR := numPageR+1;
- AnalyzePage(AdressePlus);
- end else
- if (Adresse = AdressePrecedent) then
- begin
- numPageR := numPageR-1;
- AnalyzePage(AdressePrecedent);
- end else
- if (Adresse = AdresseSuivant) then
- begin
- numPageR := numPageR+1;
- AnalyzePage(AdresseSuivant);
- end else
- begin
- AnalyzeMoviePage();
- end;
- end;
- end;
- end else
- begin
- if (ConfirmTitre = 3) then
- begin
- Adresse := LePremierFilmAdresse;
- AnalyzeMoviePage();
- end else
- begin
- SetField(fieldURL, 'Allo-cinΘ : rΘsultats multiples');
- exit;
- end;
- end;
- end;
- Page.Free;
- end;
-
- //------------------------------------------------------------------------------
- // VERIFIER LA VERSION DU SCRIPT
- //------------------------------------------------------------------------------
-
- procedure verifVersion();
- var
- Line, NewVersion, MaVersion, Telecharge : String;
- BeginPos, EndPos : Integer;
- begin
- MaVersion := '20';
- Line := GetPage('http://forum.antp.be/phpbb2/viewtopic.php?t=1453');
- BeginPos := pos('TELECHARGER LE SCRIPT ALLOCINE v', Line);
- delete(Line,1, BeginPos+31);
- EndPos := pos('du', Line);
- NewVersion := copy(Line, 1, EndPos - 2);
- PickTreeClear;
- PickTreeAdd('Votre version est la '+MaVersion+', la derniΦre est la '+NewVersion+'.', '');
- PickTreeAdd('Pour tΘlΘcharger la derniΦre version :', '');
- PickTreeAdd('Cliquez ici', 'DL');
- PickTreeAdd('Le script sera tΘlΘcharger dans le mΩme rΘpertoire que votre catalogue', '');
- PickTreeAdd('Cliquez sur annuler pour quitter', '');
- begin
- if PickTreeExec(Telecharge)=true then
- if (Telecharge = 'DL') then
- begin
- GetPicture('http://www.ifrance.com/ricoland/AlloCine.exe', True);
- end else
- begin
- exit;
- end;
- end;
- end;
-
- //------------------------------------------------------------------------------
- // FONCTION METS LE CHAMPS COMMENTAIRE A LA SUITE DU CHAMPS DESCRIPTION
- //------------------------------------------------------------------------------
- procedure moveComments();
- begin
- SetField(fieldDescription,GetField(fieldDescription)+GetField(fieldComments));
- SetField(fieldComments,'');
- end;
-
- //------------------------------------------------------------------------------
- // ANALYSE DE LA PAGE DU FILM
- //------------------------------------------------------------------------------
-
- procedure AnalyzeMoviePage();
- var
- Line, Value, AdresseCasting, AdresseSecret, AdresseGalerie, aucun, Avertissement: string;
- LineNr, IntValue: Integer;
- BeginPos, EndPos, FinPos: Integer;
- begin
- //charge la page
- Line := GetPage(Adresse);
- Avertissement := '';
- // URL
- if AdresseWebConst = True then
- begin
- if (ConfirmTitre = 3) then
- begin
- SetField(fieldURL, 'Allo-cinΘ : α verifier');
- end else
- begin
- SetField(fieldURL, URLEncode(Adresse));
- end;
-
- end;
- //translated title
- if TitreTraduitConst = True then
- begin
- BeginPos := pos('<title>', Line);
- delete(Line,1, BeginPos+6);
- EndPos := pos('</title>', Line);
- Value := copy(Line, 1, EndPos - 1);
- Value := AnsiUpFirstLetter(Value);
- Value := AnsiMixedCase(Value,' -');
- SetField(fieldTranslatedTitle, Value);
- end;
- // Picture
- if (ImageAmazonFR = True) then
- begin
- imageAmazon(Value);
- if (aucunAmazon <> 'aucune image') then
- begin
- if (pos('Toute la Galerie Photos', Line) > 0) then
- begin
- aucun := Adresse;
- delete(aucun,1,pos('.fr', aucun)+3);
- AdresseGalerie := 'http://www.allocine.fr/'+copy(aucun, 1, pos('/', aucun))+'galerie_gen_cfilm=';
- delete(aucun,1,pos('=', aucun));
- AdresseGalerie := AdresseGalerie +aucun;
- grandeTaille := 0;
- numPageG := 1;
- galerieImage(AdresseGalerie);
- end else
- begin
- BeginPos := pos('<td valign="top" style="padding:0 10 5 0">', Line);
- delete(Line,1, BeginPos);
- BeginPos := pos('width="100%"><img src=', Line);
- delete(Line,1, BeginPos+22);
- EndPos := pos('" border', Line);
- Value := copy(Line, 1, EndPos - 1);
- GetPicture(Value, False);
- end;
- end;
- end;
- if (GrandeImage = 1) then
- begin
- BeginPos := pos('<td valign="top" style="padding:0 10 5 0">', Line);
- delete(Line,1, BeginPos);
- BeginPos := pos('width="100%"><img src=', Line);
- delete(Line,1, BeginPos+22);
- EndPos := pos('" border', Line);
- Value := copy(Line, 1, EndPos - 1);
- GetPicture(Value, False);
- end else
- if (GrandeImage = 2) then
- begin
- // Adresse Galerie de photo
- if pos('Toute la Galerie Photos', Line) > 0 then
- begin
- aucun := Adresse;
- delete(aucun,1,pos('.fr', aucun)+3);
- AdresseGalerie := 'http://www.allocine.fr/'+copy(aucun, 1, pos('/', aucun))+'galerie_gen_cfilm=';
- delete(aucun,1,pos('=', aucun));
- AdresseGalerie := AdresseGalerie +aucun;
- grandeTaille := 0;
- numPageG := 1;
- galerieImage(AdresseGalerie);
- end else
- begin
- BeginPos := pos('<td valign="top" style="padding:0 10 5 0">', Line);
- delete(Line,1, BeginPos);
- BeginPos := pos('width="100%"><img src=', Line);
- delete(Line,1, BeginPos+22);
- EndPos := pos('" border', Line);
- Value := copy(Line, 1, EndPos - 1);
- GetPicture(Value, False);
- end;
- end;
- // Director
- if RealisateurConst = True then
- begin
- if pos('<h4>RΘalisΘ par ', Line) > 0 then
- begin
- Delete(Line, 1, pos('<h4>RΘalisΘ par ', Line) + 15);
- EndPos := pos('</a></h4>', Line);
- Value := copy(Line, 1, EndPos - 1);
- HTMLRemoveTags(Value);
- HTMLDecode(Value);
- SetField(fieldDirector, Value);
- end;
- end;
- // Adresse casting complet
- if pos('Voir tout le casting', Line) > 0 then
- begin
- Delete(Line, 1, pos('<h4><a href=', Line) + 12);
- EndPos := pos('.html"', Line);
- AdresseCasting := 'http://www.allocine.fr'+copy(Line, 1, EndPos + 4);
- end;
- // Actors
- if (PlusdActeurs = 1) then
- begin
- if pos('<h4>Avec ', Line) > 0 then
- begin
- Delete(Line, 1, pos('<h4>Avec ', Line) + 8);
- EndPos := pos('</h4><br />', Line);
- Value := copy(Line, 1, EndPos - 1);
- HTMLRemoveTags(Value);
- HTMLDecode(Value);
- SetField(fieldActors, Trim(Value));
- end;
- end;
- //Country
- if PaysConst = True then
- begin
- if pos('<h4>Film ', Line) > 0 then
- begin
- Delete(Line, 1, pos('<h4>Film ', Line) + 8);
- EndPos := pos('</h4>', Line);
- Value := copy(Line, 1, EndPos - 2);
- Value := AnsiUpFirstLetter(Value);
- Value := AnsiMixedCase(Value,' -');
- Value := transformCountry(Value);
- SetField(fieldCountry, Value);
- end;
- end;
- // Category
- if CategorieConst = True then
- begin
- BeginPos := pos('<h4>Genre : ', Line);
- if (BeginPos > 0) then
- begin
- Delete(Line, 1, pos('<h4>Genre : ', Line) + 11);
- EndPos := pos('</h4>', Line);
- Value := copy(Line, 1, EndPos - 1);
- Value := AnsiUpFirstLetter(Value);
- SetField(fieldCategory, Value);
- end;
- end;
- // Length
- if DureeConst = True then
- begin
- if pos('DurΘe : ', Line) > 0 then
- begin
- Delete(Line, 1, pos('DurΘe : ', Line) + 7);
- IntValue := StrToInt(copy(Line, 1, 1), 0) * 60;
- if pos('min.', Line) > 0 then
- begin
- delete(Line,1,pos('h', Line) + 1);
- Value := copy(Line, 1, pos('min.',Line)-1);
- Value := StringReplace(Value, ' ', '');
- IntValue := IntValue + StrToInt(Value, 0);
- end;
- SetField(fieldLength, IntToStr(IntValue));
- end;
- end;
- // Year
- if AnneeConst = True then
- begin
- if pos('<h4>AnnΘe de production : ', Line) > 0 then
- begin
- Delete(Line, 1, pos('<h4>AnnΘe de production : ', Line)+24);
- EndPos := pos('</h4>', Line);
- Value := copy(Line, 1, EndPos -1);
- SetField(fieldYear, Value);
- end;
- end;
- // Avertissement
- BeginPos := pos('Interdit', Line);
- if (BeginPos > 0) then
- begin
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('</h4>', Line);
- Avertissement := copy(Line, 1, EndPos - 1)+#13#10#13#10;
- SetField(fieldComments, Trim(Avertissement));
- end;
- // Original Title
- if TitreOrignalConst = True then
- begin
- BeginPos := pos('<h4>Titre original : ', Line);
- if BeginPos <> 0 then
- begin
- delete(Line,1, BeginPos+20);
- EndPos := pos('</h4>', Line);
- Value := copy(Line, 1, EndPos - 1);
- Value := AnsiUpFirstLetter(Value);
- Value := AnsiMixedCase(Value,' -');
- HTMLRemoveTags(Value);
- SetField(fieldOriginalTitle, Value);
- end else
- begin
- SetField(fieldOriginalTitle, GetField(fieldTranslatedTitle));
- end;
- end;
- // Productor + More actors
- if (PlusdActeurs = 2) then
- begin
- castingComplet(AdresseCasting);
- end;
- // Rating
- if (pos('<h4>Critiques :', Line) > 0) and (Note <> 0)then
- begin
- Delete(Line, 1, pos('<h4>Critiques :', Line) + 14);
- if pos('Presse', Line) > 0 then
- begin
- EndPos := pos('.gif', Line);
- Delete(Line, 1, EndPos-2);
- Value := copy(Line, 1, 1);
- Delete(Line, 1, EndPos+3);
- if Note = 2 then
- begin
- Avertissement := Avertissement + 'Note de la presse : ' + Value + '/4 ';
- end;
- if (Value = '0') then
- begin
- Value := '0';
- end else
- if (Value = '1') then
- begin
- Value := '2';
- end else
- if (Value = '2') then
- begin
- Value := '4';
- end else
- if (Value = '3') then
- begin
- Value := '6';
- end else
- if (Value = '4') then
- begin
- Value := '8';
- end;
- SetField(fieldRating,Value);
- end;
- if pos('Spectateurs', Line) > 0 then
- begin
- EndPos := pos('.gif', Line);
- Delete(Line, 1, EndPos-2);
- Value := copy(Line, 1, 1);
- Delete(Line, 1, EndPos+3);
- if Note = 2 then
- begin
- Avertissement := Avertissement + 'Note des spectateurs : ' + Value + '/4';
- end;
- if (Value = '0') then
- begin
- Value := '0';
- end else
- if (Value = '1') then
- begin
- Value := '2';
- end else
- if (Value = '2') then
- begin
- Value := '4';
- end else
- if (Value = '3') then
- begin
- Value := '6';
- end else
- if (Value = '4') then
- begin
- Value := '8';
- end;
- SetField(fieldRating,Value);
- end;
- if Note = 2 then
- begin
- Avertissement := Avertissement + #13#10#13#10;
- SetField(fieldComments, Avertissement);
- end;
- end;
- // Description
- if SynopsisConst = True then
- begin
- if pos('<h3><b>Synopsis', Line) > 0 then
- begin
- Delete(Line, 1, pos('<h3><b>Synopsis', Line));
- Delete(Line, 1, pos('<h4>', Line) + 3);
- EndPos := pos('</h4>', Line);
- Value := copy(Line, 1, EndPos - 1);
- HTMLRemoveTags(Value);
- HTMLDecode(Value);
- SetField(fieldDescription, Trim(Value));
- end;
- end;
- // Adresse tous les secrets de tournage
- if pos('Tous les secrets de tournage', Line) > 0 then
- begin
- aucun := Adresse;
- delete(aucun,1,pos('.fr', aucun)+3);
- AdresseSecret := 'http://www.allocine.fr/'+copy(aucun, 1, pos('/', aucun))+'anecdote_gen_cfilm=';
- delete(aucun,1,pos('=', aucun));
- AdresseSecret := AdresseSecret +aucun;
- end;
- // Commments
- if (pos('<h3><b>Secrets de tournage', Line) > 0) and (PlusdeScene = 1) then
- begin
- Delete(Line, 1, pos('<h3><b>Secrets de tournage', Line));
- Delete(Line, 1, pos('</table>', Line)+7);
- Value := Avertissement+'Secrets de tournage :'+#13#10#13#10;
- BeginPos := pos('<h4><b>', Line);
- repeat
- Delete(Line, 1, BeginPos+6);
- EndPos := pos('</b></h4>', Line);
- aucun := Trim(copy(Line, 1, EndPos - 1));
- aucun := StringReplace(aucun, #13#10, '');
- Value := Value + aucun +' :'+#13#10;
- BeginPos := pos('<h4>', Line);
- Delete(Line, 1, BeginPos-1);
- FinPos := FinPos - BeginPos+1;
- EndPos := pos('</h4>', Line);
- aucun := Trim(copy(Line, 1, EndPos - 1));
- aucun := StringReplace(aucun, #13#10, '');
- Value := Value + aucun +#13#10#13#10;
- Delete(Line, 1, EndPos-1);
- FinPos := FinPos - EndPos+1;
- BeginPos := pos('<h4><b>', Line);
- delete(Line, 1, BeginPos-8);
- FinPos := FinPos - BeginPos+8;
- aucun := copy(Line, 1, 5);
- BeginPos := pos('<h4><b>', Line);
- FinPos := pos('</table>',Line);
- if (BeginPos > FinPos) then
- BeginPos := 0;
- until ((BeginPos = 0) or (aucun = 'link1'));
- HTMLRemoveTags(Value);
- HTMLDecode(Value);
- SetField(fieldComments, Trim(Value));
- end else
- if (pos('<h3><b>Secrets de tournage', Line) > 0) and (PlusdeScene = 2) then
- begin
- La_liste := Avertissement+'Secrets de tournage :'+#13#10#13#10;
- numPage := 1;
- secretComplet(AdresseSecret);
- end;
-
- if (CommentWithSynopsis = True) then
- begin
- moveComments();
- end;
-
- DisplayResults;
- end;
-
- //------------------------------------------------------------------------------
- // ANALYSE DE LA PAGE CASTING
- //------------------------------------------------------------------------------
-
- procedure castingComplet(pageCasting: string);
- var
- Line, Role, Acteur, couple, liste, Producteur :string;
- BeginPos, EndPos, OtherPos : Integer;
- begin
- //pour eviter les time-out
- sleep(1500);
- //charge la page
- Line := GetPage(pageCasting);
- if (PlusdActeurs = 2) then
- begin
- if Pos('<b>Acteur(s)</b>', Line) > 0 then
- begin
- //liste des acteurs
- BeginPos := Pos('<b>Acteur(s)</b>', Line);
- Delete(Line, 1, BeginPos);
- BeginPos := Pos('<h5>', Line);
- liste := '';
- repeat
- // le role
- delete(Line,1,BeginPos-1);
- EndPos := Pos('</h5>', Line);
- Role := copy(Line,1,EndPos);
- HTMLRemoveTags(Role);
- delete(Line,1,EndPos);
- // le nom de l'acteur
- BeginPos := Pos('<h4><a href', Line);
- delete(Line,1,BeginPos+3);
- BeginPos := Pos('<h4>', Line);
- delete(Line,1,BeginPos-1);
- EndPos := Pos('</h4>', Line);
- Acteur := copy(Line,1,EndPos);
- HTMLRemoveTags(Acteur);
- delete(Line,1,EndPos);
- // couple acteur (r⌠le)
- if (Role <> '') then
- begin
- couple := Acteur +' ('+Role+'), ';
- end else
- begin
- couple := Acteur +', ';
- end;
- // ajout du couple dans la liste
- if (Role <> 'ScΘnariste') then
- begin
- // pour un nouvel ajout
- BeginPos := Pos('<h5>', Line);
- OtherPos := Pos('</table>',Line);
- liste := liste + couple;
- if (BeginPos > OtherPos) then
- BeginPos := 0;
- end else
- begin
- BeginPos := 0;
- end;
- until (BeginPos = 0);
- EndPos := length(liste);
- liste := copy(liste,1,EndPos-2)+'.';
- SetField(fieldActors, liste);
- end;
- // le producteur
- if Pos('<h5>Producteur', Line) > 0 then
- begin
- BeginPos := Pos('<h5>Producteur', Line);
- Delete(Line, 1, BeginPos);
- BeginPos := Pos('<h4><a href', Line);
- delete(Line,1,BeginPos+3);
- BeginPos := Pos('<h4>', Line);
- delete(Line,1,BeginPos+3);
- EndPos := Pos('</h4>', Line);
- Producteur := copy(Line,1,EndPos-1);
- SetField(fieldProducer, Producteur);
- end;
- end;
- end;
-
- //------------------------------------------------------------------------------
- // ANALYSE DE LA PAGE SECRETS DE TOURNAGE
- //------------------------------------------------------------------------------
-
- procedure secretComplet(pageSecret: string);
- var
- Line, LineSuivant, Titre, Texte, couple, pageSuivante :string;
- BeginPos, EndPos : Integer;
- begin
- //pour eviter les time-out
- sleep(1500);
- //charge la page
- Line := GetPage(pageSecret);
- LineSuivant := Line;
- numPage := numPage + 1;
- if Pos('Secrets de tournage</h2>', Line) > 0 then
- begin
- //liste des secrets
- BeginPos := Pos('Secrets de tournage</h2>', Line);
- Delete(Line, 1, BeginPos);
- BeginPos := Pos('<h4><b>', Line);
- repeat
- // le titre
- Delete(Line, 1, BeginPos+6);
- EndPos := pos('</b></h4>', Line);
- Titre := Trim(copy(Line, 1, EndPos - 1));
- BeginPos := pos('<h4>', Line);
- HTMLRemoveTags(Titre);
- Titre := StringReplace(Titre, #13#10, '');
- // le texte
- Delete(Line, 1, BeginPos-1);
- EndPos := pos('</h4>', Line);
- Texte := Trim(copy(Line, 1, EndPos - 1));
- HTMLRemoveTags(Texte);
- Texte := StringReplace(Texte, #13#10, '');
- // le couple titre : texte
- couple := Titre+' :'+#13#10+Texte+#13#10#13#10;
- Delete(Line, 1, EndPos-1);
- if (Titre <> 'Toutes les offres spΘciales') then
- begin
- // ajout du couple dans la liste
- La_liste := La_liste + couple;
- // pour un nouvel ajout
- //BeginPos := pos('<h4><b>', Line);
- //delete(Line, 1, BeginPos-8);
- BeginPos := pos('<h4><b>', Line);
- EndPos := pos('</table>',Line);
- if (BeginPos > EndPos) then
- BeginPos := 0;
- end else
- begin
- BeginPos := 0;
- end;
- until (BeginPos = 0);
- SetField(fieldComments, La_liste);
- // si on a plusieurs pages
- pageSuivante := pageSecret;
- delete(pageSuivante,1,pos('.fr', pageSuivante)+2);
- pageSuivante := copy(pageSuivante, 1, pos('.html', pageSuivante)-1);
- if pos('page',pageSuivante) = 0 then
- begin
- pageSuivante := pageSuivante+'&page='+IntToStr(numPage)+'.html';
- end else
- begin
- pageSuivante := copy(pageSuivante, 1, pos('&page=', pageSuivante)-1)+'&page='+IntToStr(numPage)+'.html';
- end;
- BeginPos := pos(pageSuivante,LineSuivant);
- if BeginPos <> 0 then
- begin
- pageSuivante := 'http://www.allocine.fr'+pageSuivante;
- secretComplet(pageSuivante);
- end;
- end;
- end;
-
- //------------------------------------------------------------------------------
- // ANALYSE DE LA PAGE GALERIE
- //------------------------------------------------------------------------------
-
- procedure galerieImage(pageGalerie: string);
- var
- Line, Value, LineSuivant, pageSuivante :string;
- BeginPos, EndPos, taille : Integer;
- begin
- //pour eviter les time-out
- sleep(1500);
- //charge la page
- Line := GetPage(pageGalerie);
- LineSuivant := Line;
- numPageG := numPageG + 1 ;
- BeginPos := pos('<td align="center" colspan="2">', Line);
- delete(Line,1, BeginPos);
- BeginPos := pos('<img src="', Line);
- delete(Line,1, BeginPos+9);
- EndPos := pos('" border', Line);
- Value := copy(Line, 1, EndPos - 1);
- delete(Line,1, EndPos);
- BeginPos := pos('alt="', Line);
- delete(Line,1, BeginPos+4);
- EndPos := pos('Ko"', Line);
- taille := StrToInt(Trim(copy(Line, 1, EndPos - 1)),0);
- grandeTaille := taille;
- LaGrandeImage := Value;
- (* if numPageG = 2 then
- begin
- LaPremiereGrandeImage := Value;
- premiereTaille := taille;
- end;
- // si on a plusieurs pages
- pageSuivante := pageGalerie;
- delete(pageSuivante,1,pos('.fr', pageSuivante)+2);
- pageSuivante := copy(pageSuivante, 1, pos('.html', pageSuivante)-1);
- if pos('page',pageSuivante) = 0 then
- begin
- pageSuivante := pageSuivante+'&page='+IntToStr(numPageG)+'.html';
- end else
- begin
- pageSuivante := copy(pageSuivante, 1, pos('&page=', pageSuivante)-1)+'&page='+IntToStr(numPageG)+'.html';
- end;
- BeginPos := pos(pageSuivante,LineSuivant);
- if BeginPos <> 0 then
- begin
- pageSuivante := 'http://www.allocine.fr'+pageSuivante;
- galerieImage(pageSuivante);
- end;
- if (premiereTaille > grandeTaille) then
- begin
- GetPicture(LaPremiereGrandeImage, False);
- end else
- begin *)
- GetPicture(LaGrandeImage, False);
- (* end; *)
- end;
-
- //------------------------------------------------------------------------------
- // AJOUTE UN COUPLE FILM / ADRESSE A LA LISTE DE RESULTAT
- //------------------------------------------------------------------------------
-
- procedure AddMoviesTitles(var Line: string);
- var
- MovieTitle, MovieAddress, aucun: string;
- StartPos, EndPos : Integer;
- begin
-
- //compte les rΘsultats
- compteur := 0;
-
- repeat
- StartPos := pos('<h4><a href=', Line);
- if StartPos > 0 then
- begin
- Delete(Line, 1, StartPos + 12);
- EndPos := pos('.html"', Line);
- MovieAddress := copy(Line, 1, EndPos+4);
- StartPos := pos('>', Line)+1;
- MovieTitle := copy(Line, StartPos, pos('</h4>', Line) - StartPos);
- MovieTitle := StringReplace(MovieTitle, ' ', ' ');
- HTMLRemoveTags(MovieTitle);
- delete(Line,1,pos('</h4>',Line)-1);
- aucun := copy(Line, 1, pos('</td>',Line)-1);
- aucun := StringReplace(aucun, ' ', ' ');
- aucun := StringReplace(aucun, #13#10, '');
- aucun := StringReplace(aucun, ' ', '');
- HTMLRemoveTags(aucun);
- // si on a des informations complΘmentaires
- if (aucun <> '') then
- begin
- MovieTitle := MovieTitle +' '+aucun;
- end;
- PickTreeAdd(MovieTitle, 'http://www.allocine.fr' + MovieAddress);
- adresse := 'http://www.allocine.fr' + MovieAddress;
- if (compteur = 0) then
- begin
- LePremierFilmAdresse := adresse;
- end;
- compteur := compteur+1;
- end;
- until (StartPos < 1);
-
- // si on a plus de rΘsultats
- StartPos := pos('Plus de films',Line);
- if StartPos <> 0 then
- begin
- AdressePlus := 'http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1&page='+IntToStr(numPageR);
- PickTreeAdd('Plus de rΘsultats',AdressePlus);
- end;
- numTemp := numPageR-1;
- strTemp := IntToStr(numTemp);
- if pos('<a href="/recherche/?motcle='+MovieName+'&rub=1&page='+strTemp,Line) <> 0 then
- begin
- AdressePrecedent := 'http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1&page='+strTemp;
- PickTreeAdd('Films prΘcΘdents',AdressePrecedent);
- end;
- numTemp := numPageR+1;
- strTemp := IntToStr(numTemp);
- if pos('<a href="/recherche/?motcle='+MovieName+'&rub=1&page='+strTemp,Line) <> 0 then
- begin
- AdresseSuivant := 'http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1&page='+strTemp;
- PickTreeAdd('Films suivants',AdresseSuivant);
- end;
-
- end;
-
- //------------------------------------------------------------------------------
- // RECUPERE GRANDE IMAGE AMAZON.FR
- // d'aprΦs le script de DaJoss (amazon.fr images uniquement)
- //------------------------------------------------------------------------------
-
- procedure imageAmazon(title : String);
- var
- Page: TStringList;
- adresseRecherche, Line, lAddress : String;
- LineNr: Integer;
- begin
- adresseRecherche := 'http://www.amazon.fr/exec/obidos/search-handle-url/index=dvd-fr&field-title='+UrlEncode(title);
- Page := TStringList.Create;
- Page.Text := GetPage(adresseRecherche);
- if pos('Sur ce DVD', Page.Text) > 0 then
- begin
- AnalyzeMoviePageAmazon(adresseRecherche);
- end else
- if pos('satisfaisante pour votre recherche sur', Page.Text) > 0 then
- begin
- //ShowMessage('Aucune image sur amazon pour : ' + MovieName);
- aucunAmazon := 'aucune image' ;
- exit;
- end else
- if pos('Les articles les plus recherchés correspondant à', Page.Text) > 0 then
- begin
- //PickTreeClear;
- LineNr := 0;
- LineNr := FindLine('résultats au total pour', Page, LineNr);
- if LineNr > -1 then
- begin
- //PickTreeAdd('Films TrouvΘs sur amazon pour ' + MovieName + ' :', '');
- AddMoviesTitlesAmazon(Page, LineNr);
- end;
- (*if PickTreeExec(lAddress) then
- AnalyzeMoviePageAmazon(lAddress);*)
- end else
- begin
- PickTreeClear;
- LineNr := 0;
- LineNr := FindLine('résultats au total pour', Page, LineNr);
- if LineNr > -1 then
- begin
- //PickTreeAdd('Films TrouvΘs pour ' + MovieName + ' :', '');
- AddMoviesTitlesAmazon(Page, LineNr);
- end;
- (*if PickTreeExec(lAddress) then
- AnalyzeMoviePageAmazon(lAddress);*)
- end;
- end;
-
- procedure AnalyzeMoviePageAmazon(lAdresse: String);
- var
- Line, Value : string;
- BeginPos, EndPos: Integer;
-
- begin
- Line := GetPage(lAdresse);
- BeginPos := pos('<a href="http://images-eu.amazon.com/images/P/', Line);
- Delete(Line, 1, BeginPos);
- BeginPos := pos('src="', Line) + 4;
- Delete(Line, 1, BeginPos);
- EndPos := pos('"', Line);
- Value := copy(Line, 1, EndPos - 1);
- Value := StringReplace(Value, 'MZZZZZZZ', 'LZZZZZZZ'); // Change l'URL pour prendre la grande au lieu de la petite image
- Sleep(500); // Attente 2X seconde : Evite les timeout sur le serveur
- GetPicture(Value, False); // False = stocke l'image dans la base
- end;
-
- procedure AddMoviesTitlesAmazon(Page: TStringList; var LineNr: Integer);
- var
- Line: string;
- MovieTitle, MovieAddress: string;
- StartPos: Integer;
- StartImg: Integer;
- StartLst: Integer;
- LastLine: Integer;
-
- begin
- //repeat
- LineNr := LineNr + 1;
- Line := Page.GetString(LineNr);
- LastLine := Page.count;
- StartPos := pos('<a href=/exec/obidos/ASIN/', Line);
- StartImg := pos('<img src="http://images-eu.amazon.com/images/', Line);
- StartLst := pos('</a>', Line);
- if StartPos+StartImg+StartLst < StartPos+StartPos+StartPos-StartImg-StartLst then
- begin
- Startpos := Startpos + 9;
- MovieAddress := copy(Line, StartPos, pos('qid', Line) - StartPos);
- StartPos := pos('<b>', Line) + 3;
- MovieTitle := copy(Line, StartPos, (StartPos + 150)- StartPos);
- HTMLDecode(Movietitle);
- //PickTreeAdd(MovieTitle, 'http://www.amazon.fr/' + MovieAddress);
- AnalyzeMoviePageAmazon('http://www.amazon.fr/' + MovieAddress);
- end;
- //until (LineNr > Lastline);
- end;
-
- //------------------------------------------------------------------------------
- // NETTOIE LE TITRE DU FICHIER POUR AVOIR LE TITRE DE FILM
- //------------------------------------------------------------------------------
-
- function cleanTitle(title : String) : string;
- var
- i,j, fin : Integer;
- temp : String;
-
- begin
- title := AnsiUpperCase(title);
-
- if title <> '' then
- begin
- // Nettoie les tags fichiers, merci Atmosfear pour les tags
- i:=pos('.DVD',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.DIVX',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.FREN',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.GERM',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.INT',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.LIM',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.PROP',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.REPACK',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.SUBB',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.UNSUB',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.WS',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.XVID',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.AC3',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
- i:=pos('.UNRAT',title);
- if i <> 0 then
- begin
- title := copy(title,1,i-1);
- end;
-
- title := StringReplace(title, '.', ' ');
- title := StringReplace(title, ',', ' ');
- title := StringReplace(title, ':', '');
- title := StringReplace(title, '-', '');
- title := StringReplace(title, ' ', ' ');
-
- i := 0;
- // Nettoie les tags de team
- if (pos('(',title) <> 0) then
- begin
- i := pos('(',title);
- temp := copy(title,0,i-1);
- j := pos(')',title);
- fin := Length(title);
- title := temp + copy(title,j+1,fin);
- end;
-
- if (pos('[',title) <> 0) then
- begin
- i := pos('[',title);
- temp := copy(title,1,i-1);
- j := pos(']',title);
- fin := Length(title);
- title := temp + copy(title,j+1,fin);
- end;
-
- title := AnsiLowerCase(title);
- title := AnsiUpFirstLetter(title);
- title := AnsiMixedCase(title,' -');
- end;
- result := title;
- end;
-
- //------------------------------------------------------------------------------
- // TRANSFORME NATIONALITE EN PAYS
- //------------------------------------------------------------------------------
-
- function transformCountry(country : String) : string;
- begin
- country := AnsiLowerCase(country);
- country := StringReplace(country, 'amΘricain', 'USA');
- country := StringReplace(country, 'japonais', 'Japon');
- country := StringReplace(country, 'franτais', 'France');
- country := StringReplace(country, 'tha∩landais', 'Tha∩lande');
- country := StringReplace(country, 'sud-corΘen', 'CorΘe');
- country := StringReplace(country, 'espagnol', 'Espagne');
- country := StringReplace(country, 'italien', 'Italie');
- country := StringReplace(country, 'britannique', 'Grande-Bretagne');
- country := StringReplace(country, 'hong-kongais', 'Hong-Kong');
- country := StringReplace(country, 'nΘo-zΘlandais', 'Nouvelle-ZΘlande');
- country := StringReplace(country, 'chinois', 'Chine');
- country := StringReplace(country, 'ta∩wanais', 'Ta∩wan');
- country := StringReplace(country, 'mexicain', 'Mexique');
- country := StringReplace(country, 'brΘsilien', 'BrΘsil');
- country := StringReplace(country, 'allemand', 'Allemagne');
- country := StringReplace(country, 'belge', 'Belgique');
- country := StringReplace(country, 'suΘdois', 'SuΦde');
- country := StringReplace(country, 'danois', 'Danemark');
- country := StringReplace(country, 'finlandais', 'Finlande');
- country := StringReplace(country, 'islandais', 'Islande');
- country := StringReplace(country, 'nΘerlandais', 'Pays-Bas');
- country := StringReplace(country, 'portugais', 'Portugal');
- country := StringReplace(country, 'canadien', 'Canada');
- country := StringReplace(country, 'australien', 'Australie');
- country := StringReplace(country, 'russe', 'Russie');
- country := StringReplace(country, 'tchΦque', 'RΘpublique TchΦque');
- country := StringReplace(country, 'chilien', 'Chili');
- country := StringReplace(country, 'hongrois', 'Hongrie');
- country := StringReplace(country, 'argentin', 'Argentine');
- country := StringReplace(country, 'roumain', 'Roumanie');
- country := StringReplace(country, '', '');
- result := country;
- end;
-
- //------------------------------------------------------------------------------
- // PROGRAMME PRINCIPAL
- //------------------------------------------------------------------------------
-
- begin
- if CheckVersion(3,4,0) then
- begin
- numPageR := 1;
- MovieName := GetField(fieldTranslatedTitle);
- if MovieName = '' then
- MovieName := GetField(fieldOriginalTitle);
- MovieName := cleanTitle(MovieName);
- if (ConfirmTitre = 1) then
- begin
- if Input('AllocinΘ.fr by ScorEpioN', 'Entrez le titre du film :', MovieName) then
- begin
- if Pos('allocine.', MovieName) > 0 then
- begin
- adresse := MovieName;
- AnalyzeMoviePage();
- end else
- begin
- AnalyzePage('http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1');
- end;
- end;
- end else
- begin
- if (premiereExecution = 0) then
- begin
- premiereExecution := -1;
- PickTreeClear;
- PickTreeAdd('Vous allez executer le script AllocinΘ sans confirmation', '');
- PickTreeAdd('Cliquez ici pour continuer', 'Oui');
- PickTreeAdd('Cliquez sur annuler pour ne pas executer le script', '');
- begin
- if PickTreeExec(Reponse)=true then
- if (Reponse = 'Oui') then
- begin
- AnalyzePage('http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1');
- end;
- end;
- end else
- begin
- AnalyzePage('http://www.allocine.fr/recherche/?motcle='+UrlEncode(MovieName)+'&rub=1');
- end;
- end;
- end else
- ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
- end.
-
-